\defmodule {LogisticGen}

This class implements random variate generators for the 
{\em logistic\/} distribution. Its parameters are $\alpha$ and $\lambda > 0$.
Its density function is 
\begin{htmlonly}
\eq
    f(x) = \lambda e^{-\lambda(x-\alpha)}/ 
           [(1 + e^{-\lambda(x-\alpha)})^2] \mbox{ for } -\infty<x<\infty.
\endeq
\end{htmlonly}
\begin{latexonly}
\eq
    f(x) = \frac {\lambda e^{-\lambda(x-\alpha)}} 
           {\left(1 + e^{-\lambda(x-\alpha)}\right)^2}
           \qquad\mbox{ for } -\infty<x<\infty.     \eqlabel{eq:flogistic}
\endeq
\end{latexonly}

The (non-static) \texttt{nextDouble} method simply calls \texttt{inverseF} on the
distribution.

\bigskip\hrule

\begin{code}
\begin{hide}
/*
 * Class:        LogisticGen
 * Description:  random variate generators for the logistic distribution
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.randvar;\begin{hide}
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
\end{hide}

public class LogisticGen extends RandomVariateGen \begin{hide} {
   protected double alpha = -1.0;
   protected double lambda = -1.0;
    
\end{hide}
\end{code}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection* {Constructors}

\begin{code}

   public LogisticGen (RandomStream s, double alpha, double lambda) \begin{hide} {
      super (s, new LogisticDist(alpha, lambda));
      setParams (alpha, lambda);
   }\end{hide}
\end{code} 
\begin{tabb} Creates a logistic random variate generator with parameters
  $\alpha =$ \texttt{alpha} and $\lambda =$ \texttt{lambda},
  using stream \texttt{s}. 
\end{tabb}
\begin{code}

   public LogisticGen (RandomStream s) \begin{hide} {
      this (s, 0.0, 1.0);
   }\end{hide}
\end{code} 
\begin{tabb} Creates a logistic random variate generator with parameters
  $\alpha = 0$ and $\lambda =1$,
  using stream \texttt{s}. 
\end{tabb}
\begin{code}

   public LogisticGen (RandomStream s, LogisticDist dist) \begin{hide} {
      super (s, dist);
      if (dist != null)
         setParams (dist.getAlpha(), dist.getLambda());
   }\end{hide}
\end{code}
\begin{tabb}  Creates a new generator for the logistic distribution 
  \texttt{dist} and stream \texttt{s}.
\end{tabb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
\subsubsection* {Methods}
\begin{code}

   public static double nextDouble (RandomStream s,
                                    double alpha, double lambda)\begin{hide} {
      return  LogisticDist.inverseF (alpha, lambda, s.nextDouble());
   }
\end{hide}
\end{code}
\begin{tabb}  Generates a new variate from the {\em logistic\/} distribution
   with parameters $\alpha = $~\texttt{alpha} and $\lambda = $~\texttt{lambda},
   using stream \texttt{s}.
\end{tabb}
\begin{code}

   public double getAlpha()\begin{hide} {
      return alpha;
   }\end{hide}
\end{code}
\begin{tabb} Returns the parameter $\alpha$ of this object.
\end{tabb}
\begin{code}

   public double getLambda()\begin{hide} {
      return lambda;
   }\end{hide}
\end{code}
\begin{tabb} Returns the parameter $\lambda$ of this object.
\end{tabb}
\begin{hide}\begin{code}

   protected void setParams (double alpha, double lambda) {
      if (lambda <= 0.0)
         throw new IllegalArgumentException ("lambda <= 0");
      this.lambda = lambda;
      this.alpha = alpha;
   }
\end{code}
\begin{tabb} Sets the parameter $\alpha$ and $\lambda$ of this object.
\end{tabb}
\begin{code}
}
\end{code}
\end{hide}
